//
//  StoryTableViewCell.m
//  HappinessTrip
//
//  Created by dllo on 15/10/12.
//  Copyright © 2015年 蓝鸥科技. All rights reserved.
//

#import "StoryTableViewCell.h"
#import "UIImageView+WebCache.h"
#import "Fit.h"

@implementation StoryTableViewCell
-(void)dealloc
{
    [_topImageView release];
    [_contentLabel release];
    [super dealloc];
}
-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self createViews];
    }
    return self;
}
-(void)createViews
{
    _topImageView = [[UIImageView alloc]init];
    [self.contentView addSubview:_topImageView];
    [_topImageView release];
    _contentLabel = [[UILabel alloc]init];
    [self.contentView addSubview:_contentLabel];
    [_contentLabel release];
}


-(void)setDetail:(Detail_list *)detail
{
    if (_detail != detail) {
        [_detail release];
        _detail = [detail retain];
    }
    [_topImageView sd_setImageWithURL:[NSURL URLWithString:_detail.photo_s] placeholderImage:[UIImage imageNamed:@"dengdai"]];
   
}

-(void)setwidth:(NSInteger)width height:(NSInteger)height string:(NSString *)string
{
    CGFloat bili = width / 335;
    CGFloat imageHeight = height / bili;
    _topImageView.frame = CGRectMake(20 * W, 20 * H, 335 * W, imageHeight);
    _topImageView.layer.cornerRadius = 10;
    _topImageView.layer.masksToBounds = YES;
    NSDictionary *dic = [NSDictionary dictionaryWithObjectsAndKeys:[UIFont systemFontOfSize:15], NSFontAttributeName, nil];
    CGRect rect = [string boundingRectWithSize:CGSizeMake(335 * W, CGFLOAT_MAX) options:NSStringDrawingUsesLineFragmentOrigin attributes:dic context:nil];
    _contentLabel.text = string;
    _contentLabel.numberOfLines = 0;
    _contentLabel.font = [UIFont systemFontOfSize:15];
    _contentLabel.frame = CGRectMake(_topImageView.frame.origin.x, _topImageView.frame.origin.y + _topImageView.frame.size.height + 10, _topImageView.frame.size.width, rect.size.height);
}







- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
